#include<bits/stdc++.h>
#define int long long
using namespace std;

inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar();}
	return x*f;
}
int n;
string s;

map<string,bool> mp;
void dfs(string s){
	if(mp[s]) return;
	mp[s]=1;
	for(int i=0;i<s.size();i++){
		if(i+1<s.size()&&((s[i]=='A'&&s[i+1]=='A')||(s[i]=='B'&&s[i+1]=='B')||(s[i]=='B'&&s[i+1]=='A'))){
			string t;t.clear();
			for(int j=0;j<i;j++) t=t+s[j];
			for(int j=i+2;j<s.size();j++) t=t+s[j];
			dfs(t);
		}
	}
}

signed main(){
    freopen("song.in","r",stdin);
	freopen("song.out","w",stdout);
	cin>>s;
	n=s.size();
	if(n<=20){
		dfs(s);
		printf("%lld",(int)mp.size());
	}
	else{
		if(s[0]=='A'){
			int c=(n-1)/2;
			printf("%lld",c+1);
		}
		else{
			int c=n/2;
			printf("%lld",c+1);
		}
	}
    return 0;
}